home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
IRIX Base Documentation 1998 November
/
IRIX 6.5.2 Base Documentation November 1998.img
/
usr
/
share
/
catman
/
p_man
/
cat3
/
f90
/
cvmg.z
/
cvmg
Wrap
Text File
|
1998-10-30
|
7KB
|
168 lines
CVMG(3I) Last changed: 1-6-98
NNAAMMEE
CCVVMMGGMM, CCVVMMGGNN, CCVVMMGGPP, CCVVMMGGTT, CCVVMMGGZZ - Conditional vector merge functions
SSYYNNOOPPSSIISS
CCVVMMGGMM (([II==]_i,, [JJ==]_j,, [KK==]_k))
CCVVMMGGNN (([II==]_i,, [JJ==]_j,, [KK==]_k))
CCVVMMGGPP (([II==]_i,, [JJ==]_j,, [KK==]_k))
CCVVMMGGTT (([II==]_i,, [JJ==]_j,, [KK==]_k))
CCVVMMGGZZ (([II==]_i,, [JJ==]_j,, [KK==]_k))
IIMMPPLLEEMMEENNTTAATTIIOONN
UNICOS, UNICOS/mk, and IRIX systems
SSTTAANNDDAARRDDSS
CF90 and MIPSpro 7 Fortran 90 compiler extension to Fortran 90
DDEESSCCRRIIPPTTIIOONN
At run time, _k is tested. You can use the conditional vector merge
(CVMG) functions when an IIFF statement involving arrays prevents
vectorization of a loop. The compiler can vectorize almost all such
loops, but these functions can be used in older codes. Scalar
arguments can also be used with these functions.
CVMG functions cannot be passed as arguments. They are elemental
functions.
These functions test for the following:
* CCVVMMGGMM tests for minus (negative). _i is returned if _k < 0. _j is
returned if _k >= 0.
* CCVVMMGGNN tests for nonzero. _i is returned if _k is not equal to 0. _j
is returned if _k = 0.
* CCVVMMGGPP tests for positive or zero. _i is returned if _k >= 0. _j is
returned if _k < 0.
* CCVVMMGGTT tests for true. _i is returned if _k is true. _j is returned if
_k is false.
* CCVVMMGGZZ tests for zero. _i is returned if _k = 0. _j is returned if _k
is not equal to 0.
These functions accept the following arguments:
_i Can be of type logical, Boolean, integer, real, or Cray pointer.
See the RETURN VALUES section of this man page for more
information on how the type of _i affects the return value.
_j Can be of type logical, Boolean, integer, real, or Cray pointer.
See the RETURN VALUES section of this man page for more
information on how the type of _j affects the return value.
_k Can be of type logical, Boolean, integer, real, or Cray pointer.
See the RETURN VALUES section of this man page for more
information on how the type of _k affects the return value.
If _k satisfies the condition tested by the function (for example, in
CCVVMMGGPP, if _k is positive), the first argument (_i) is returned as the
function result. If _k does not satisfy the condition tested by the
function, _j is returned as the function result.
For operands other than type logical, the vector merge functions are
not generic with respect to data typing. They accept arithmetic
values of different types but interpret them as Boolean type (that is,
as bit patterns). The returned function value is also Boolean.
Therefore, the function reference CCVVMMGGTT((11..00,,22..00,,..TTRRUUEE..)) is not type
real, with a value of 1.0, but a Boolean value that acts the same as
1.0 in a floating-point operation.
A problem can arise if you assume that the function reference is type
real and use it in an expression or assignment that causes automatic
type conversion. For example, if you use the function reference in a
context where an integer is needed, the result is not valid because
1.0 and 1 have different bit patterns.
Because CVMG function values are Boolean, a binary operation involving
two CVMG functions uses integer arithmetic. This can produce
unexpected results in assignments such as the following in which AA, BB,
CC, and DD are real:
X = CVMGT(A,B,LOGIC1) + CVMGT(C,D,LOCIC2)
! Integer arithmetic, invalid results
However, when used in an expression with another operand, a CVMG
function value takes on the type of the other operand, without any
explicit type conversion. For example, the following expression uses
real arithmetic:
X = 1.0 + CVMGT(2.0,3.0,LEXP) ! Valid (types agree)
The following suggestions explain how to prevent bugs when using these
functions:
* Use only one CVMG function in a given expression. If you use more
than one CVMG function in an expression, use explicit type
conversion. This does not generate any additional code. For
example:
X = REAL(CVMGT(1.0,2.0,LTEST)) + REAL(CVMGT(X,Y,LTEST2))
* Ensure that the assignment type matches the function argument.
Example:
X = CVMGT(1.0,2.0,LTEST) ! Valid
X = REAL(CVMGT(1,2,LTEST)) ! Valid (uses explicit type conversion)
X = CVMGT(1,2,LTEST) ! Invalid (type mismatch)
* Never use mixed typing in the first two arguments of a CCVVMMGGTT
function. Example:
CVMGT(1,2.0,LTEST) ! DO NOT DO THIS
The names of these intrinsics cannot be passed as arguments.
NNOOTTEESS
The CVMG intrinsic functions are outmoded. Refer to the _F_o_r_t_r_a_n
_L_a_n_g_u_a_g_e _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, _V_o_l_u_m_e _3, publication SR-3905, for
information on outmoded features and their preferred standard
alternatives.
RREETTUURRNN VVAALLUUEESS
For CCVVMMGGMM, CCVVMMGGNN, CCVVMMGGPP, CCVVMMGGTT, and CCVVMMGGZZ, the return value is either
type Boolean, logical, integer, or real, depending on the type of _i
and jj.
On UNICOS and UNICOS/mk systems, type logical is returned if _i is of
type logical; otherwise it is of type Boolean.
On IRIX systems, if _i and _j are both of type real, the result type is
also real. If _i is of type logical, type logical is returned. In all
other cases, the return value is of type integer.
EEXXAAMMPPLLEESS
Consider the following code:
DO I = N,M
X(I) = A(I)
IF (B(I) .GT. C(I)) X(I) = D(I)
END DO
This could be rewritten as follows:
DO I = N,M
X(I) = CVMGT(D(I), A(I), B(I).GT.C(I))
END DO
The following rewrite would also be valid:
DO I = N,M
X(I) = CVMGP( D(I), A(I), B(I) - C(I))
END DO
SSEEEE AALLSSOO
_I_n_t_r_i_n_s_i_c _P_r_o_c_e_d_u_r_e_s _R_e_f_e_r_e_n_c_e _M_a_n_u_a_l, publication SR-2138, for the
printed version of this man page.